package com.lin.jdk.juc.queue;

import java.util.PriorityQueue;

public class PriorityQueueTest {


    public static void main(String[] args) {
        PriorityQueue<Ele> queue = new PriorityQueue();

        queue.add(new Ele(1));
        queue.add(new Ele(2));
        queue.add(new Ele(4));
        queue.add(new Ele(6));
        queue.add(new Ele(8));
        queue.add(new Ele(10));
        queue.add(new Ele(12));
        queue.add(new Ele(14));
        queue.add(new Ele(15));
        queue.add(new Ele(9));

        System.out.println("------------ queue => " + queue.toString());
        queue.forEach(o -> System.out.println(o.order));

        System.out.println("queue.poll() = " + queue.poll().order);
        queue.forEach(o -> System.out.println(o.order));
        System.out.println("queue.poll() = " + queue.poll().order);
        queue.forEach(o -> System.out.println(o.order));
        System.out.println("queue.poll() = " + queue.poll().order);
        queue.forEach(o -> System.out.println(o.order));
        System.out.println("queue.poll() = " + queue.poll().order);
        queue.forEach(o -> System.out.println(o.order));
        System.out.println("queue.poll() = " + queue.poll().order);
        queue.forEach(o -> System.out.println(o.order));
    }

}

class Ele implements Comparable<Ele> {

    int order;

    Ele(int o) {
        this.order = o;
    }

    @Override
    public int compareTo(Ele o) {
        return this.order - o.order;
    }
}

